import javax.swing.*;
import java.util.concurrent.TimeUnit;

/**
 * @author 杨宇
 * @date Created on 2016/6/14.
 */
public class SubitSwingPropram extends JFrame {
    JLabel label;
    public SubitSwingPropram() {
        super("Hello Swing");
        label = new JLabel("A Label");
        add(label);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setSize(300, 100);
        setVisible(true);
    }

    static SubitSwingPropram ssp;

    public static void main(String[] args) throws InterruptedException {
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                ssp=new SubitSwingPropram();
            }
        });

        TimeUnit.SECONDS.sleep(2);
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                ssp.label.setText("Hey! This is Different!");
            }
        });
    }
}
